package com.project.service.Impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.project.bean.DisasterPrevention.ClassBean;
import com.project.mapper.IClassMapper;
import com.project.service.IClassService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;


@Service
@Transactional
public class IClassServiceImpl extends ServiceImpl<IClassMapper, ClassBean> implements IClassService {

    @Resource
    private IClassMapper classMapper;

    @Override
    public IPage<ClassBean> findCutClass(int pagNo, int pageSize, String className, String regionName) {


        Page<ClassBean> page = new Page<>(pagNo,pageSize);
        classMapper.findCutClass(page,className,regionName);
        return classMapper.findCutClass(page,className,regionName);
    }

    @Override
    public void addClass(ClassBean classBean) {

        this.classMapper.addClass(classBean);

    }

    @Override
    public ClassBean findClass(int classId) {

        ClassBean classBean = classMapper.findClass(classId);

        return classBean;
    }

    @Override
    public void updateClass(int classId, String classPerson, String classPersonTel) {

        ClassBean classBean = new ClassBean();

        classBean.setClassId(classId);
        classBean.setClassPerson(classPerson);
        classBean.setClassPersonTel(classPersonTel);

        this.baseMapper.updateById(classBean);


    }


    @Override
    public List<ClassBean> findAllCls() {
        return this.baseMapper.selectList(null);
    }
}
